package com.zhupanlin.zhyl.common.exception;


import com.zhupanlin.zhyl.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/11/16 23:32
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.fail();
    }


    @ExceptionHandler(Zhylxception.class)
    @ResponseBody
    public Result error(Zhylxception e) {
        e.printStackTrace();
        return Result.build(e.getCode(), e.getMessage());
    }

}
